package com.itheima.controller;

import com.itheima.exception.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ExceptionController {


    @RequestMapping("/testMyException")
    public String testMyException() throws Exception {
        System.out.println("testException执行了...");

        try {
            // 模拟异常
            int a = 10/0;
        } catch (Exception e) {
            // 打印异常信息
            e.printStackTrace();
            // 抛出自定义异常信息
            throw new MyException("查询所有用户出现错误了...");
        }
        return "success";
    }

}
